<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<%@ include file="/pub/head_latest.inc"%>
<%--样式 --%>
<link href="${baseURL}/themes/plugin/bootstrap/css/bootstrap.css"
	rel="stylesheet" type="text/css" />
<link
	href="${baseURL}/themes/plugin/bootstrap-dialog/css/bootstrap-dialog.css"
	rel="stylesheet" type="text/css" />
<link href="${baseURL}/themes/plugin/bootstrapTable/bootstrap-table.css"
	rel="stylesheet" type="text/css" />
<%-- 时间选择器 --%>
<link
	href="${baseURL}/themes/plugin/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css"
	rel="stylesheet" media="screen">
	<!-- 滚动条 custom scrollbar plugin -->
	<link
		href="${baseURL}/themes/plugin/scrollbar/jquery.mCustomScrollbar.css"
		rel="stylesheet" type="text/css" />
	<link href="${baseURL}/themes/blue/css/sys.css" rel="stylesheet"
		type="text/css" />
	<link rel="stylesheet"
		href="${baseURL}/assets/css/font-awesome-02.min.css" />
	<link href="${baseURL}/themes/blue/css/fonts/iconfont.css"
		rel="stylesheet" type="text/css" />

	<%--八斗通用字体图标 --%>
	<link href="${baseURL}/themes/common/bd-iconfont/iconfont.css"
		rel="stylesheet" type="text/css" />

	<%--JS文件 --%>
	<script src="${baseURL}/js/jquerys/jquery-1.12.1.min.js"
		type="text/javascript"></script>
	<script src="${baseURL}/themes/plugin/bootstrap/js/bootstrap.min.js"
		type="text/javascript"></script>
	<script
		src="${baseURL}/themes/plugin/bootstrap-dialog/js/bootstrap-dialog.js"
		type="text/javascript"></script>


	<script
		src="${baseURL}/themes/plugin/bootstrapTable/bootstrap-table.js"
		type="text/javascript"></script>
	<script
		src="${baseURL}/themes/plugin/bootstrapTable/locale/bootstrap-table-zh-CN.min.js"
		type="text/javascript"></script>

	<!-- 滚动条 custom scrollbar plugin -->
	<script
		src="${baseURL}/themes/plugin/scrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
	<%-- 时间选择器 --%>
	<script type="text/javascript"
		src="${baseURL}/themes/plugin/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js"
		charset="UTF-8"></script>
	<script type="text/javascript"
		src="${baseURL}/themes/plugin/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"
		charset="UTF-8"></script>

	<script src="${baseURL}/js/sys-event.js" type="text/javascript"></script>

	<script src="${baseURL}/js/sdAppFrameworkCommon.js"
		type="text/javascript"></script>
	<script src="${baseURL}/js/sdAppFrameworkAddressBook.js"
		type="text/javascript"></script>
	<script src="${baseURL}/js/addressBook.js" type="text/javascript"></script>

	<script src="${baseURL}/js/ajaxfileupload.js" type="text/javascript"></script>
	<script src="${baseURL}/js/common-upload.js" type="text/javascript"></script>
	<script src="${baseURL}/js/BT.js" type="text/javascript"></script>
<title>待办维护列表-${basePageTitle}</title>
<style type="text/css">

.bootstrap-dialog-message{text-align:center;}
.bootstrap-dialog-message>p{text-align:center;}
.bootstrap-dialog-message>h4{text-align:center;}
.bootstrap-dialog-footer-buttons{text-align:center;}
</style>
</head>
<body class="FrameRightBg">
	<div class="FrameRight" id="FrameRightContent">
		<!-- 这里定义了转发进入的TAB对应的菜单ID，也是TAB的属性ID值 -->
		<input type="hidden" name="menuId" id="menuId" value="${param.menuId}" />
		<div id="mainsearch" style="width: 100%;margin-left: 0px"">
		<%@ include file="/WEB-INF/jsp/module/view/new_selector_form.jsp"%>
			<form id="formsearch" method="post">
				<%-- <table>
					<tr>
						<td align="left" class="l-table-edit-td">标题ddd:</td>
						<td align="left" class="l-table-edit-td"><input name="title"
							type="text" id="title" ltype="text" class="form-control"
							inputWidth="400" ltype="text" placeholder="标题" /></td>
						<td align="left" class="l-table-edit-td">到达日期:</td>
						<td align="left" class="l-table-edit-td"><input
							name="arriveTimeStart" type="text"
							class="ui-datepicker-input form-control" id="arriveTimeStart"
							inputWidth="100" realOnly="true" ltype="date" /></td>
						<td>-</td>
						<td align="left" class="l-table-edit-td"><input
							name="arriveTimeEnd" type="text"
							class="ui-datepicker-input form-control" id="arriveTimeEnd"
							inputWidth="100" realOnly="true" ltype="date" /></td>
						<td align="left" class="l-table-edit-td">环节:</td>
						<td align="left" class="l-table-edit-td"><input
							name="handlerNodeName" type="text" id="handlerNodeName"
							ltype="text" class="form-control" inputWidth="150" ltype="text"
							placeholder="环节" /></td>
						<td align="left" class="l-table-edit-td">处理人:</td>
						<td align="left" class="l-table-edit-td">
							<!-- 	                	<input name="handler" type="hidden" id="handler" value="" class="form-control"/>-->
							<input name="handlerName" type="text" id="handlerName"
							ltype="text" class="form-control" inputWidth="150" ltype="text"
							placeholder="处理人" />
						</td>
					</tr>
					<tr>
						<td align="right" class="l-table-edit-td">状态:</td>
						<td align="left" class="l-table-edit-td"><input
							type="checkbox" id="flgStatue_1" value="1" name="flgStatue1"
							class="field" checked="checked" /> <img
							src='${baseURL}/images/state/undeal_16.png' alt='待办' />待办&nbsp;
							<input type="checkbox" id="flgStatue_2" value="2"
							name="flgStatue2" class="field" checked="checked" /> <img
							src='${baseURL}/images/state/deal_16.png' alt='已办' />已办&nbsp; <input
							type="checkbox" id="flgStatue_11" value="11" name="flgStatue11"
							class="field" checked="checked" /> <img
							src='${baseURL}/images/state/unread_16.png' alt='待阅' />待阅&nbsp;
							<input type="checkbox" id="flgStatue_12" value="12"
							name="flgStatue12" class="field" checked="checked" /> <img
							src='${baseURL}/images/state/read_16.png' alt='已阅' />已阅</td>
						<td align="left" class="l-table-edit-td">处理日期:</td>
						<td align="left" class="l-table-edit-td"><input
							name="handleTimeStart" type="text"
							class="ui-datepicker-input form-control" id="handleTimeStart"
							inputWidth="100" realOnly="true" ltype="date" /></td>
						<td>-</td>
						<td align="left" class="l-table-edit-td"><input
							name="handleTimeEnd" type="text"
							class="ui-datepicker-input form-control" id="handleTimeEnd"
							inputWidth="100" realOnly="true" ltype="date" /></td>
						<td align="left" class="l-table-edit-td"
							style="padding-left: 30px">
							<button type="button" id="btnSearch"
								class="l-button l-button-submit">
								<i class="bd bd-search"></i> 搜索
							</button>
						</td>
						<td align="left" class="l-table-edit-td">
							<button type="reset" id="btnReset" class="l-button l-button-test">
								<i class="bd bd-exchange"></i> 重置
							</button>
						</td>
					</tr>
				</table> --%>
				<div class="selector-form"></div>
			</form>
		</div>
		<div class="common-option" style="margin-top: 5px">
			<div class="inner">
				<button id="add" type="button" class="btn btn-icon"
					onclick="FF_TransferClickEvent(this)">
					<i class="icon iconfont bd-send"></i>转办
				</button>
				<button id="resume" type="button" class="btn btn-icon"
					onclick="FF_TrunkDoneClickEvent(this)">
					<i class="icon iconfont bd-redo"></i>转为已处理
				</button>
				<button id="delete" type="button" class="btn btn-icon"
					onclick="FF_TrunkUndoClickEvent(this)">
					<i class="icon iconfont bd-redo-square"></i>转为未处理
				</button>
				<button id="setPanel" type="button" class="btn btn-icon"
					onclick="FF_DeletedClickEvent(this)">
					<i class="l-icon l-icon-a fa fa-minus-square-o"></i>删除
				</button>
				<button id="setPanel" type="button" class="btn btn-icon"
					onclick="FF_RefleshClickEvent(this)">
					<i class="icon iconfont bd-sync"></i>刷新
				</button>
			</div>
		</div>
		<!-- 表格列表 -->
		<div class="common-table">
			<table id="maingrid" style="margin-left: 0px; width: 100%"></table>
		</div>

	</div>
	<script type="text/javascript">
  	$(function(){
		$(document).keypress(function(event){
			if (event.keyCode == 13) { // 13表示回车键
				$("#btnSearch").click();
				return false;
			}
		});
		
		/*  var handlerSelect = $("#handlerName").ligerComboBox({
			 onButtonClick : function(){
				 alert("onButtonClick");
			 },
			 onBeforeOpen  : function(){
				 var g = handlerSelect;
				 $(g).sdAddressBook({multi : 1, onReturn : function(result){
		        	 	 if(!result) return false;
		        		$("#handler").val(result.outputValue);
		        	 	$("#handlerName").val(result.outputText);
					 }
				 });
				 return false;
			 }
		 }); */
	 });
      //列表结构
      function queryParams(params){
    	  	var data = [];
			if(selector != null){
				data = selector.getSelectorValue();
			}
	    	return {
				pageNo: params.pageNumber,
				perPageSize: params.pageSize,
				searchParam: JSON.stringify(data)
			}
    	}
      function initTable() {
      		$('#maingrid').bootstrapTable({
      			url:'${baseURL}/workmaintain/workmaintainlist/listJSON.do',
      			method: 'post',
    			contentType: "application/x-www-form-urlencoded",
           		sidePagination: "server",
           		queryParams: queryParams,
           		queryParamsType:"undenfied",
           	 dataField: "Rows",
             totalField:"Total",
             striped: true,                      //是否显示行间隔色
    	        pageNumber:1,                       //初始化加载第一页，默认第一页
    	     	pagination: true,
    	        clickToSelect: true,                //是否启用点击选中行
                uniqueId: "id",                 //每一行的唯一标识，一般为主键列
           		columns: [{
                    checkbox: true
                },{
                    field: 'status',
                    title: '状态',
    	               formatter: function (value, row, index) {
    	            	   if(value==1){
    	            		   return "待办";
    	            	   }else if(value==2){
    	            		   return "已办";
    	            	   }else if(value==11){
    	            		   return "待阅";
    	            	   }else if(value==12){
    	            		   return "已阅";
    	            	   }else{
    	            		   return "-";
    	            	   }
    	               }
                },{
                       field: 'title',
                       title: '标题',
       	               formatter: function (value, row, index) {
       	                   return value;  
       	               }
                   }, {
                       field: 'nodeName',
                       title: '环节',
                       formatter: function (value, Rows, index) {
                    	   return value;
    	               }
    			   }, {
                       field: 'createDate',
                       title: '到达时间',
                       formatter: function (value, Rows, index) {
                    	   return value;
    	               }
    			   }, {
                       field: 'dealDate',
                       title: '处理时间',
                       formatter: function (value, Rows, index) {
                    	   return value;
    	               }
    			   }, {
                       field: 'senderName',
                       title: '发送人',
                       formatter: function (value, Rows, index) {
                    	   return value;
    	               }
    			   }, {
                       field: 'srcHandlerName',
                       title: '原处理人',
                       formatter: function (value, Rows, index) {
                    	   return value;
    	               }
    			   }, {
                       field: 'handlerName',
                       title: '处理人',
                       formatter: function (value, Rows, index) {
                    	   return value;
    	               }
    			   }]
      		})
    	}
      
      $(function () {
    		initTable();
    		$("#maingrid").css("text-align","center");
    		}) 
    //搜索事件
	 $("#btnSearch").click(function(e){
		 var title = $("#title").val();
		 var arriveTimeStart = $("#arriveTimeStart").val();
		 var arriveTimeEnd = $("#arriveTimeEnd").val();
		 var handlerNodeName = $("#handlerNodeName").val();
		 var handlerName = $("#handlerName").val();
		 var handleTimeStart = $("#handleTimeStart").val();
		 var handleTimeEnd = $("#handleTimeEnd").val();
		 if ($("#flgStatue_1").is(':checked')){
			 var flgStatue1 = $("#flgStatue_1").val(); 
		 }
		 if ($("#flgStatue_2").is(':checked')){
			 var flgStatue_2 = $("#flgStatue_2").val(); 
		 }
		 if ($("#flgStatue_11").is(':checked')){
			 var flgStatue_11 = $("#flgStatue_11").val(); 
		 }
		 if ($("#flgStatue_12").is(':checked')){
			 var flgStatue_12 = $("#flgStatue_12").val(); 
		 }
		 var opt = {
			        silent: true,
			        query:{
			        	title:title,
			        	arriveTimeStart:arriveTimeStart,
			        	arriveTimeEnd:arriveTimeEnd,
			        	handlerNodeName:handlerNodeName,
			        	handlerName:handlerName,
			        	handleTimeStart:handleTimeStart,
			        	handleTimeEnd:handleTimeEnd,
			        	flgStatue1:flgStatue1,
			        	flgStatue_2:flgStatue_2,
			        	flgStatue_11:flgStatue_11,
			        	flgStatue_12:flgStatue_12
			        }
			    };
			$("#maingrid").bootstrapTable('refresh',opt);
		 
	 });

     //重置事件
     $("#btnReset").click(function(e){
		 $("#title").val("");
		 $("#arriveTimeStart").val("");
		 $("#arriveTimeEnd").val("");
		 $("#handlerNodeName").val("");
		 $("#handlerName").val("");
		 $("#handleTimeStart").val("");
		 $("#handleTimeEnd").val("");
     });
     
     $('#arriveTimeStart').datetimepicker({
 	    format: 'yyyy-mm-dd hh:ii',
 	    language: 'zh-CN',
 	　　　　　　weekStart: 1,
 	　　　　　　todayBtn: 1,//显示‘今日’按钮
 	　　　　　　autoclose: 1,
 	　　　　　　todayHighlight: 1,
 	　　　　　　startView: 2,
 	　　　　　　minView: 1,  //Number, String. 默认值：0, 'hour'，日期时间选择器所能够提供的最精确的时间选择视图。
 	　　　　　　clearBtn:true,//清除按钮
 	　　　　　　forceParse: 0
 	});
     $('#arriveTimeEnd').datetimepicker({
 	    format: 'yyyy-mm-dd hh:ii',
 	    language: 'zh-CN',
 	　　　　　　weekStart: 1,
 	　　　　　　todayBtn: 1,//显示‘今日’按钮
 	　　　　　　autoclose: 1,
 	　　　　　　todayHighlight: 1,
 	　　　　　　startView: 2,
 	　　　　　　minView: 1,  //Number, String. 默认值：0, 'hour'，日期时间选择器所能够提供的最精确的时间选择视图。
 	　　　　　　clearBtn:true,//清除按钮
 	　　　　　　forceParse: 0
 	});
     $('#handleTimeStart').datetimepicker({
 	    format: 'yyyy-mm-dd hh:ii',
 	    language: 'zh-CN',
 	　　　　　　weekStart: 1,
 	　　　　　　todayBtn: 1,//显示‘今日’按钮
 	　　　　　　autoclose: 1,
 	　　　　　　todayHighlight: 1,
 	　　　　　　startView: 2,
 	　　　　　　minView: 1,  //Number, String. 默认值：0, 'hour'，日期时间选择器所能够提供的最精确的时间选择视图。
 	　　　　　　clearBtn:true,//清除按钮
 	　　　　　　forceParse: 0
 	});
     $('#handleTimeEnd').datetimepicker({
 	    format: 'yyyy-mm-dd hh:ii',
 	    language: 'zh-CN',
 	　　　　　　weekStart: 1,
 	　　　　　　todayBtn: 1,//显示‘今日’按钮
 	　　　　　　autoclose: 1,
 	　　　　　　todayHighlight: 1,
 	　　　　　　startView: 2,
 	　　　　　　minView: 1,  //Number, String. 默认值：0, 'hour'，日期时间选择器所能够提供的最精确的时间选择视图。
 	　　　　　　clearBtn:true,//清除按钮
 	　　　　　　forceParse: 0
 	});

      //工具条事件
      //刷新
      function FF_RefleshClickEvent(btnItem){
    	  FF_Reload();
      }
      //转办事件
      function FF_TransferClickEvent(btnItem){
    	  var selectedRow = $('#maingrid').bootstrapTable('getSelections');
          if (!selectedRow || selectedRow.length <= 0) { BT.showWarning("请先选择需要转办的记录行!"); return false;}
          for(var i=0; i < selectedRow.length; i++){
        	  if(selectedRow[i].status == 2 || selectedRow[i].status == 12){
        		  BT.showWarning("您选择的记录行中包含已办（已阅）记录，已办（已阅）不能进行转办操作!"); return false;
        	  }
          }
        //弹出选人框
          $(this).sdAddressBook({multi : 1, onReturn : function(result){
        	  if(!result) return false;
        	  BT.showConfirm("转办","您确定将选定的待办转办至["+result.outputText+"]吗?",function(){
        		  $.post("${baseURL}/workmaintain/workmaintainsave/transfer.do",
               			{ids : LG.serialIdParam(selectedRow), target : result.outputValue},
               			function(data){
               				if(data){
	                     		if(data.hasOk) BT.showSuccess("操作成功!",function(){FF_Reload()});
	                     		else{
	       	                		BT.showError("操作失败!"+data.message);
	       	                	}
	                     	}
	       	            }
               		)
               	});
          }});
      }
      //转为待办事件
      function FF_TrunkUndoClickEvent(btnItem){
    	  var selectedRow = $('#maingrid').bootstrapTable('getSelections');
          if (!selectedRow || selectedRow.length <= 0) { BT.showWarning("请先选择需要操作的记录行!"); return false;}
          for(var i=0; i < selectedRow.length; i++){
        	  if(selectedRow[i].status == 1 || selectedRow[i].status == 11){
        		  BT.showWarning("您选择的记录行中包含待办（待阅）记录，待办（待阅）不需要再进行转为未处理操作!"); return false;
        	  }
          }
          BT.showConfirm("转为未处理","您确定将选定的记录行转为未处理吗?",function(){
        	  $.getJSON("${baseURL}/workmaintain/workmaintainsave/trunk.do",{ids : LG.serialIdParam(selectedRow), status : 1},
        			function(data){
     					if(data){
               				if(data.hasOk) BT.showSuccess("操作成功!",function(){FF_Reload()});
               				else{
 	                			BT.showError("操作失败!"+data.message);
 	                		}
     					}
               		}
 			  )
          });
      }
       //转为已办事件
      function FF_TrunkDoneClickEvent(btnItem){
    	  var selectedRow = $('#maingrid').bootstrapTable('getSelections');
          if (!selectedRow || selectedRow.length <= 0) { BT.showWarning("请先选择需要操作的记录行!"); return false;}
          for(var i=0; i < selectedRow.length; i++){
        	  if(selectedRow[i].status == 2 || selectedRow[i].status == 12){
        		  BT.showWarning("您选择的记录行中包含已办（已阅）记录，已办（已阅）不需要再进行转为已处理操作!"); return false;
        	  }
          }
          BT.showConfirm("转为已处理","您确定将选定的记录行转为已处理吗?",function(){
        	  $.getJSON("${baseURL}/workmaintain/workmaintainsave/trunk.do",{ids : LG.serialIdParam(selectedRow), status : 2},
        			function(data){
     					if(data){
               				if(data.hasOk) BT.showSuccess("操作成功!",function(){FF_Reload()});
               				else{
 	                			BT.showError("操作失败!"+data.message);
 	                		}
     					}
               		}
 			  )
          });
      }
      //删除事件
      function FF_DeletedClickEvent(btnItem){
    	  var selectedRow = $('#maingrid').bootstrapTable('getSelections');
          if (!selectedRow || selectedRow.length <= 0) { BT.showWarning("请先选择需要删除的记录行!"); return false;}
          BT.showConfirm("删除","您确定删除选定的记录行吗?",function(){
        	  $.getJSON("${baseURL}/workmaintain/workmaintaindelete/delete.do",{ids : LG.serialIdParam(selectedRow)},
        			function(data){
     					if(data){
               				if(data.hasOk) BT.showSuccess("操作成功!",function(){FF_Reload()});
               				else{
 	                			BT.showError("操作失败!"+data.message);
 	                		}
     					}
               		}
 			  )
          });
      }
      //一个重新加载数据方法，该方法主要作为外部框架调用使用
      function FF_Reload(){
    	  $("#maingrid").bootstrapTable('refresh');
      }
      // 渲染选择器
    	var searchGrid = {
    		$element: $('#maingrid'),
    		load: function(){
    			this.$element.bootstrapTable('refresh');
    		}
    	}
      	var operation = [{id:1,text:"待办"},{id:2,text:"已办"},{id:11,text:"待阅"},{id:12,text:"已阅"}];
     	var selector = $.initSelector(searchGrid, [
								{id:"dealDate",name:"处理时间",valueText:"全部",isExtended:false,selectType:5,formate:"yyyy-MM-dd",startDay:null,endDay:null,type:0,measurement:null},
  								{id:"genDate",name:"到达时间",valueText:"全部",isExtended:false,selectType:5,formate:"yyyy-MM-dd",startDay:null,endDay:null,type:0,measurement:null},
  								{id:"status",name:"状态",value:null,valueText:"全部",isExtended:false,selectType:9},
  								{id:"handlerName",name:"处理人",value:"",isExtended:false,selectType:1},
  								{id:"nodeName",name:"环节",value:"",isExtended:false,selectType:1},
            	        		{id:"worklistItemTitle",name:"标题",value:"",isExtended:false,selectType:1}
            	        		   
            	        		   ], null, [{id:"status",name:"状态",data:operation}]);
  </script>
</body>
</html>
